using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Elementum
{
    class TwinkleTransition : Transition
    {
        protected Animation _back;
        public delegate void TransitionDoneActionHandler();
        public event TransitionDoneActionHandler TransitionDoneAction;
        Random rnd1;
        public List<int> time = new List<int>();

        public TwinkleTransition(int start, int end)
            : base(start, end)
        {
            _back = new Animation("images/system/black", new Point(800, 480));
            _back.Alpha = 0;
            rnd1 = new Random();
        }

        protected override void OnTransition()
        {
            base.OnTransition();
            int i = rnd1.Next(2);
            if (i == 0)
                _back.Alpha = 0.02f;
            else
                _back.Alpha = 0.98f;
        }

        protected override void TransitionDone()
        {
            //_stage.TransitionList.Remove(this);
            //if (_stage.TransitionList.Count() == 0)
            //    _stage.LockTouch = false;
            _back.Alpha =1;
            if (TransitionDoneAction != null)
                TransitionDoneAction();
        }

        public override void OnDraw(SpriteBatch spriteBatch)
        {
            base.OnDraw(spriteBatch);

            spriteBatch.Begin();
            _back.OnDraw(spriteBatch, new Vector2(400, 240));
            spriteBatch.End();
        }

        public override void Update()
        {
            base.Update();

        }

    }
}
